/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package firstProject;

import java.awt.List;
import java.awt.Point;
import java.util.Comparator;

/**
 *
 * @author asculx
 */
public class Polvere implements Comparable<Polvere>, Comparator<Polvere> {

    Point Position;
    int quantity;
    int distance;

    public Polvere(int x, int y, int quantity) {
        this.quantity = quantity;
        Position = new Point(x, y);
    }

    public Polvere(Point Position, int quantity, int distance) {
        this.Position = Position;
        this.quantity = quantity;
        this.distance = distance;
    }

    @Override
    public int compareTo(Polvere next) {

        int absDist = (Math.abs(distance - next.distance));
        int absQuant = (Math.abs(quantity - next.quantity));

        if (distance <= next.distance) {
            return -1;
        }else if(distance == next.distance){
            if(quantity > next.quantity){
                return -1;
            }else{
                return 1;
            }
        }
        else {
            return 1;
        }
    }

    public Point getPosition() {
        return Position;
    }

    public void setPosition(Point Position) {
        this.Position = Position;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public int getDistance() {
        return distance;
    }

    public void setDistance(int distance) {
        this.distance = distance;
    }

    @Override
    public String toString() {
        return "{" + Position.toString() + " distance= " + distance + " polvere= " + quantity + "}";
    }

    
    @Override
    public int compare(Polvere t, Polvere t1) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
